<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
     <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head >
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<jsp:include page="/WEB-INF/backstage/util.jsp"/>

</head>
<body>
<form class="form-inline" role="form"  method="post" action="findshop1">
<table>
<tr>

<td><label>店铺名称</label></td>
<td><input class="form-control" type="text" name ="shop_name" id="shop_name"></td>
<td><label>主营项目</label></td>
<td><select class="form-control" name="shop_project" id="shop_project">
  <option value="">--请选择</option>
  <option value="1">美容</option>
  <option value="2">美甲</option>
  </select>
  </td>

<td> <label>状态</label></td>
<td><select class="form-control" name="show_status" id="show_status">
  <option value=""></option>
  <option value="0">停用</option>
  <option value="1">启用</option>
  </select></td> 
  <td rowspan="4"><button type="submit" class="btn btn-primary">查询</button>&nbsp
  <button type="button" class="btn btn-primary" id="clear">重置</button>&nbsp
  <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">添加</button></td>
  
</tr>
<tr>
<td><label>电话</label></td>
<td><input type="text" class="form-control" name ="shop_phone" id="shop_phone"></td>
<td><label>店铺简称</label></td>
<td><input class="form-control" type="text" name ="short_name" id="short_name"></td>
<td><label>营业执照号</label></td>
<td><input class="form-control" type="text" name ="shop_license" id="shop_license"></td>
</tr> 
</table>
</form>

<table border="1" width="1000" class="table table-striped" class="table table-hover">
<tr style="background-color: #E6EEF8">
<td>&nbsp&nbsp&nbsp&nbsp</td>
<td>店铺编号</td>
<td>店铺名称</td>
<td>店铺简称</td>
<td>店铺主营项目</td>
<td>营业执照号</td>
<td>店铺电话</td>
<td>状态</td>
<td>更新时间</td>
<td></td>

</tr>
<c:forEach items="${info.list }" var="list">
<tr style="background-color: ">
<td id="t1">&nbsp&nbsp&nbsp&nbsp</td>
<td>${list.shop_id }</td>
<td>${list.shop_name }</td>
<td>${list.short_name }</td>
<td>${list.shop_project=="1"?"美容":"美甲" }</td>
<td>${list.shop_license} </td>
<td>${list.shop_phone }</td>
<td>${list.show_status=="1"?"启用":"禁用" }</td>
<td>${list.modify_time }</td>
<td>
<a href="deleteshop/${list.shop_id  }"  class="btn btn-primary btn-xs" role="button">删除</a>
<a href="toupdateshop2/${list.shop_id  }"  class="btn btn-primary btn-xs" role="button">修改</a>
</td>
</tr>
</c:forEach>
</table>
<a href="#"  onclick="toup()">上一页</a>&nbsp;&nbsp;&nbsp;
<a href="#"   onclick="tonext()">下一页</a>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog" style="width: 750px;" style="height :400px">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 align="center" class="modal-title" id="myModalLabel">添加</h4>
      </div>
      <div class="modal-body">
       
       <form  method="post" id="form1" enctype="multipart/form-data" > 
 <table  >
        <tr>
        <td><label for="shop_name" >商店名称</label></td>
        <td>
			<div class="form-group">
			
			<div class="col-sm-10">
				<input type="text" class="form-control" id="shop_name"
					name="shop_name">
			</div>
			</div>
		</td>
          <td><label for="short_name" >商家简称</label></td>
        <td>
        <div class="form-group">
			
			<div class="col-sm-10">
				<input type="text" class="form-control" id="short_name"
					name="short_name" >
			</div>
			</div>
        </td>
        </tr>
        <tr>
         <td><label for="shop_phone" >电话</label></td>
        <td>
        <div class="form-group">
			<div class="col-sm-10">
				<input type="text" class="form-control" id="shop_phone2"
					name="shop_phone" >
			</div>
			</div>
        </td>
         <td><label for="owner_id" >店主账号</label></td>
        <td>
        <div class="form-group">
			<div class="col-sm-10">
		<select  name="owner_id" id="owner_id" class="form-control">
		
		<c:forEach items="${list2 }" var="list2">
		<option value="${list2.shop_user_id }">${list2.account }</option>
		</c:forEach>
		</select>
		</div>
			</div>
		</td>
        </tr>
         <tr>
        <td><label for="month_cash_in" >月目标现金收入</label></td>
        <td>
			   <div class="form-group">
			<div class="col-sm-10">
				<input type="text" class="form-control" id="month_cash_in"
					name="month_cash_in" >
			</div>
			</div>
		</td>
          <td><label for="month_expend_in" >月目标消耗收入</label></td>
        <td>
         <div class="form-group">
			<div class="col-sm-10">
				<input type="text" class="form-control" id="month_expend_in"
					name="month_expend_in" >
			</div>
			</div>
        </td>
        </tr>
        <tr>
        <td><label for="file" >缩略图片</label></td>
        <td>
         <div class="form-group">
			<div class="col-sm-10">
        <input type="file" class="form-control" name ="file">
        </div>
			</div>
        </td>
         <td><label for="file" >封面图片</label></td>
        <td><div class="form-group">
			<div class="col-sm-10">
			<input type="file" class="form-control" name ="file">
			 </div>
			</div>
			</td>
        </tr> 
        <tr>
         <td><label for="shop_license" >营业执照号</label></td>
        <td>
        <div class="form-group">
			<div class="col-sm-10">
				<input type="text" class="form-control" id="shop_license"
					name="shop_license" >
			</div>
			</div>
        </td>
        <td><label for="shop_project" >店铺主营项目</label></td>
        <td>
         <div class="form-group">
			<div class="col-sm-10">
        <select  name="shop_project" id="shop_project2" class="form-control">
		<option value="1">美容</option>
		<option value="2">美甲</option>
		</select>
		</div>
			</div>
        </td>
        </tr>
        
          <tr align="center">
           
        <td colspan="4">
        <button type="button" class="btn btn-primary" id="clear2">重置</button>
        <input type="button" class="btn btn-primary" value="提交" onclick="addbtn()"></td>
        </tr>
        </table>
        
    </form>
        
      </div>
</div>
  </div>
</div> 
</body>
</html>
<script type="text/javascript">
function addbtn(){
	var bootstrapValidator = $("#form1").data('bootstrapValidator'); //获取表单对象
	bootstrapValidator.validate();//触发全部验证 
	if(bootstrapValidator.isValid()){
		form1.action="${pageContext.request.contextPath }/insertshop";
		form1.submit();
	}
}



$(function(){
	$("#form1").bootstrapValidator({
		live : 'enabled',
		feedbackIcons : { //验证时显示的图标
			valid : 'glyphicon glyphicon-ok', //正确图标
			invalid : 'glyphicon glyphicon-remove', //错误图标
			validating : 'glyphicon glyphicon-refresh' //正在更新图标
		},
		fields : { //要验证哪些字段
			shop_name : {
				validators : {//验证
					notEmpty : { //非空判断
						message : '店铺名称不能为空' 
					}
					
				}
			},	
			short_name : {
				validators : {//验证
					notEmpty : { //非空判断
						message : '商家简称不能为空' 
					}
				}
			},	
			shop_phone:{
				validators : {//验证
					notEmpty : { //非空判断
						message : '电话不能为空' 
					}
				},
				regexp: {
					regexp: /[0-9-()]{7,18}/,
					message: '联系电话格式错误'
				},
			},
			month_cash_in : {
				validators : {//验证
					notEmpty : { //非空判断
						message : '月目标现金收入不能为空' 
					}
					}
				},
				month_expend_in : {
					validators : {//验证
						notEmpty : { //非空判断
							message : '月目标现金收入不能为空'
						}
						}
					},
					shop_license : {
					validators : {//验证
						notEmpty : { //非空判断
							message : '营业执照号不能为空' 
						}
						}
					}
					
		}
	});
});







$("#clear").click(
		function() {
			$("#shop_name").val("");
			$("#shop_project").val("");
			$("#show_status").val("");
			$("#shop_phone").val("");
			$("#short_name").val("");
			$("#shop_license").val("");
		}
	);
	
$("#clear2").click(
		function() {
			$("#account").val("");
			$("#username").val("");
			$("#month_cash_in").val("");
			$("#month_expend_in").val("");
			$("#idno").val("");
			$("#shop_project2").val("");
			$("#shop_phone2").val("");
			$("#status").val("");
		}
	);
	

//下一页
function tonext(){

	/* var page=${pb.currentPage+1}>${pb.totalpage}?${pb.totalpage}:${pb.currentPage+1};
	alert("下一页"+page); */
	document.forms[0].action="findshop1?page="+${info.nextPage};
	document.forms[0].submit();
}
//上一页
function toup(){
	/* var page=${pb.currentPage-1}<1?1:${pb.currentPage-1};
	alert("上一页"+page); */
	document.forms[0].action="findshop1?page="+${info.prePage};
	document.forms[0].submit();
}
</script>